package com.ptit.piclient;

import com.ptit.piclient.R;
import com.ptit.piclient.tools.ImageAdapter;

import android.os.Bundle;
//import android.os.StrictMode;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;
//import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener, OnItemClickListener {
	GridView gridView ;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		gridView = (GridView) findViewById(R.id.gridview);
		ImageAdapter adapter = new ImageAdapter(this);
		gridView.setAdapter(adapter);
		
		gridView.setOnItemClickListener(this);
		
		/*if (android.os.Build.VERSION.SDK_INT > 9) {
		    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
		    StrictMode.setThreadPolicy(policy);
		}*/		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		View view = arg1;
		TextView txt = (TextView)view.findViewById(R.id.imgText);
		String text = (String) txt.getText();
		if(text.equals("All Songs")){
			//Move to All song activity
			Intent i = new Intent(this, AllSongActivity.class);
			i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
			startActivity(i);
		}
		if(text.equals("Albums")){
			//Move to albums activity
		}
		if(text.equals("Artists")){
			//Move to artist activity
		}
		if(text.equals("Playlists")){
			//Move to Playlists activity
		}
		if(text.equals("Settings")){
			//Move to Settings activity
		}
	}

}
